package com.xique.park.controller.auto;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkingOrder;
import com.xique.park.service.service.IParkingOrderService;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.page.TableDataInfo;

/**
 * 停车流水订单
-单次停车唯一标识Controller
 * 
 * @author xique
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/parkingOrder")
public class ParkingOrderController extends BaseController
{
    @Autowired
    private IParkingOrderService parkingOrderService;

    /**
     * 查询停车流水订单
-单次停车唯一标识列表
     */
    @PreAuthorize(hasPermi = "park:order:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkingOrder parkingOrder)
    {
        startPage();
        List<ParkingOrder> list = parkingOrderService.selectParkingOrderList(parkingOrder);
        return getDataTable(list);
    }

    /**
     * 导出停车流水订单
     */
    @PreAuthorize(hasPermi = "park:order:export")
    @Log(title = "停车流水订单 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingOrder parkingOrder) throws IOException
    {
        List<ParkingOrder> list = parkingOrderService.selectParkingOrderList(parkingOrder);
        ExcelUtil<ParkingOrder> util = new ExcelUtil<ParkingOrder>(ParkingOrder.class);
        util.exportExcel(response, list, "停车流水订单 ");
    }

    /**
     * 获取停车流水订单
-单次停车唯一标识详细信息
     */
    @PreAuthorize(hasPermi = "park:order:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(parkingOrderService.selectParkingOrderById(id));
    }

    /**
     * 新增停车流水订单
-单次停车唯一标识
     */
    @PreAuthorize(hasPermi = "park:order:add")
    @Log(title = "停车流水订单 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingOrder parkingOrder)
    {
        return toAjax(parkingOrderService.insertParkingOrder(parkingOrder));
    }

    /**
     * 修改停车流水订单
-单次停车唯一标识
     */
    @PreAuthorize(hasPermi = "park:order:edit")
    @Log(title = "停车流水订单 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingOrder parkingOrder)
    {
        return toAjax(parkingOrderService.updateParkingOrder(parkingOrder));
    }

    /**
     * 删除停车流水订单
-单次停车唯一标识
     */
    @PreAuthorize(hasPermi = "park:order:remove")
    @Log(title = "停车流水订单 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkingOrderService.deleteParkingOrderByIds(ids));
    }
}
